package com.example.myapplication2030606131wjw;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView trnYonghu;
    private EditText tenZhanghu;
    private EditText trnMima;
    private Button tenBorttnDengru;
    private Button tenBorttnChongzhi;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

       //输入获取内容
        tenBorttnDengru.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String accout = tenZhanghu.getText().toString();
                String password = trnMima.getText().toString();

                //输入不完整的内容
                if (accout.length() == 0) {
                    Log.i("登入", "请输入用户名 ");

                } else if (password.length() == 0) {
                    Log.i("登入", "请输入密码");
                } else {


                    //判断
                    if (accout.equals("admin ") & password.equals("123456")) {
                        Log.i("登入", "登入成功 ");

                    } else {
                        Log.i("登入", "登入失败 ");
                    }
                    tenBorttnDengru.setText(null);
                    tenBorttnChongzhi.setText(null);
                }
            }
        });
    }
    //  点击重置按钮是，两个输入框内容清空



    private void initView() {
        trnYonghu = (TextView) findViewById(R.id.trn_yonghu);
        tenZhanghu = (EditText) findViewById(R.id.ten_zhanghu);
        trnMima = (EditText) findViewById(R.id.trn_mima);
        tenBorttnDengru = (Button) findViewById(R.id.ten_borttn_dengru);
        tenBorttnChongzhi = (Button) findViewById(R.id.ten_borttn_chongzhi);
    }
}